/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.manager.search;

import br.com.foxline.model.ActCep;
import br.com.foxline.service.ActCepService;
import br.com.foxline.util.ActionTab;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author ely
 */
@ManagedBean
@ViewScoped
public class ManagerSearchActCep implements Serializable{

    @EJB
    ActCepService actCepService;
   
    private List<ActCep> actCeps;
    private ActCep actCep;
    private ActCep editActCep;
    private ActionTab position;
    private boolean visibleTab;

    public ManagerSearchActCep() {
    }

    @PostConstruct
    public void init() {
        actCeps = new ArrayList<ActCep>();
        actCep = new ActCep();
        editActCep = new ActCep();
        position = new ActionTab();
        visibleTab = true;

    }

    public void reinit() {
        actCeps = new ArrayList<ActCep>();
        actCep = new ActCep();
    }

    public void searchActCep() {
        actCeps = actCepService.findActCep(actCep);
    }

    public void update(){
         actCepService.updateActCep(editActCep);
    }
    
    
    public void cancelSearch() {
        position.setIndexTab(0);
        reinit();
    }
    
     public void cancelEdit() {
        visibleTab = true;
        position.positionTab(1);
    }

    public void resgateActCep(ActCep actCep) {
        this.editActCep = actCep;
        visibleTab = false;
        position.positionTab(2);
    }
    
    
    
    public List<ActCep> getActCeps() {
        return actCeps;
    }

    public void setActCeps(List<ActCep> actCeps) {
        this.actCeps = actCeps;
    }

    public ActCep getActCep() {
        return actCep;
    }

    public void setActCep(ActCep actCep) {
        this.actCep = actCep;
    }

    public ActionTab getPosition() {
        return position;
    }

    public void setPosition(ActionTab position) {
        this.position = position;
    }

    public boolean isVisibleTab() {
        return visibleTab;
    }

    public void setVisibleTab(boolean visibleTab) {
        this.visibleTab = visibleTab;
    }

    public ActCep getEditActCep() {
        return editActCep;
    }

    public void setEditActCep(ActCep editActCep) {
        this.editActCep = editActCep;
    }
    
    
    
    
}
